package com.example.cathouse;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao    // Database access object
public interface CatDao {
    @Insert
    void insertCats(Cat... cats);

    @Update
    void updateCats(Cat... cats);

    @Delete
    void deleteCats(Cat... cats);

    @Query("DELETE FROM CAT")
    void deleteAllCats();

    @Query("SELECT * FROM CAT ORDER BY ID DESC")
    LiveData<List<Cat>> getAllCatsLive();

    @Query("SELECT * FROM CAT WHERE ID = :catId")
    LiveData<Cat> getCat(int catId);

    @Query("SELECT * FROM CAT WHERE cat_name LIKE :pattern ORDER BY ID DESC")
    LiveData<List<Cat>> findCatsWithPattern(String pattern);
}
